//! @Author: DengLibin
//! @Date: Create in 2023-11-07 08:58:18
//! @Description: 中间件
use axum::{body::Body, http::Request, middleware::Next, response::Response};
use log::debug;

pub mod auth;
pub mod timing;

/// @Author: DengLibin
/// @Date: Create in 2023-11-07 09:02:49
/// @Description: 自定义中间件
pub async fn my_middleware(request: Request<Body>, next: Next) -> Response {
    // do something with `request`...
    // let o = request.headers().get("User-Agent");
    // if let Some(header_value) = o {
    //     if let Ok(s) = header_value.to_str() {
    //         debug!("User-Agent:{}", s);
    //     }
    // }

    
    debug!("-------------------------->middleware:my_middleware start");
    let response = next.run(request).await;
    debug!("-------------------------->middleware:my_middleware end");
    // do something with `response`...
    // let o = response.headers().get("Content-Type");
    // if let Some(header_value) = o {
    //     if let Ok(s) = header_value.to_str() {
    //         debug!("response Content-Type:{}", s);
    //     }
    // }

    response
}


